{include file="public_head" /}
<!-- upload -->
<link href="__STATIC__/css/uploads.css" rel="stylesheet">
<!-- upload -->
<link href="__STATIC__/css/uploads.css" rel="stylesheet">
<!-- upload_arr -->
<link href="__STATIC__/plupload/plupload.css" rel="stylesheet">
<body class="nav-md">

<div class="container body">

    <div class="main_container">

        {include file="public_sidebar,public_nav" /}
        <!-- page content -->
        <div class="right_col" role="main">
            <div class="">

                <div class="page-title">
                    <div class="title_left">
                        <h3>优惠券记录管理</h3>
                    </div>
                </div>
                <div class="clearfix"></div>
                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_title">
                                <h2>{$mate_title}
                                    <!--<small>different form elements</small>-->
                                </h2>
                                <ul class="nav navbar-right panel_toolbox">
                                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                    </li>
                                    <li><a class="close-link"><i class="fa fa-close"></i></a>
                                    </li>
                                </ul>
                                <div class="clearfix"></div>
                            </div>
                            <div class="x_content">
                                <br/>
                                <form class="form-horizontal form-label-left" enctype="multipart/form-data" action=""
                                      method="post" id="registerForm">


                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">会员信息：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            {$item.username}
                                        </div>
                                    </div>

                                    <div class="divider-dashed"></div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">红包标题：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            {$item.title}
                                        </div>
                                    </div>

                                    <div class="divider-dashed"></div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">优惠券实际金额（满减金额）：</label>
                                        <div class="col-md-1 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            {$item.total_price}（{$item.minus_price}）
                                        </div>
                                    </div>


                                    <div class="divider-dashed"></div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">优惠券限制时间：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请输入报名时间"  id="interval_timer"
                                                   class="form-control col-md-7 col-xs-12" name="interval_timer"
                                                   {present name="$item.id"}
                                                   value="{:date('Y-m-d',$item.start_time)} / {:date('Y-m-d',$item.end_time)}"
                                                   {/present}
                                            datatype="*"  id="interval_timer"
                                            nullmsg="请输入报名时间！" errormsg="请输入报名时间！"
                                            >
                                        </div>
                                    </div>

                                    <div class="divider-dashed"></div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">领取时间：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            {php}
                                            if(strpos($item['create_time'],'-') !== false){
                                            echo $item['create_time'];
                                            }else{
                                            echo date('Y-m-d H:i:s',$item['create_time']);

                                            }

                                            {/php}
                                        </div>
                                    </div>

                                    <div class="divider-dashed"></div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">状态：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <label class="radio_box">
                                                <input type="radio" name="status" id="state_1" class="cartradio"
                                                       value="1"
                                                       datatype="*"
                                                       nullmsg="请选择启用状态！" errormsg="请选择启用状态！"
                                                       {eq name='item.status|default=""' value='1' }
                                                       checked
                                                       {/eq}
                                                >&nbsp;&nbsp;
                                                <label for="state_1"></label>
                                                <span>未使用</span>
                                                &nbsp;&nbsp;
                                            </label>
                                            <label class="radio_box">
                                                <input type="radio" name="status" id="state_2" class="cartradio"
                                                       value="2"
                                                       datatype="*"
                                                       nullmsg="请选择启用状态！" errormsg="请选择启用状态！"
                                                       {eq name='item.status|default=""' value='2' }
                                                       checked
                                                       {/eq}
                                                >&nbsp;&nbsp;
                                                <label for="state_2"></label>
                                                <span>已使用</span>
                                                &nbsp;&nbsp;
                                            </label>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">上传组图：【720*365】</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">

                                            <div class="uploader white">
                                                <input type="button" id="logo_upload_btn" class="button" value="批量上传" />
                                            </div>

                                            <div id="logo_upload_area" style='width:80%'>
                                                <div id='photos_area' class="photos_area clearfix">

                                                    {if condition="($Request.action eq 'update') && (($item.multi_pic neq 'N;') && ($item.multi_pic neq ''))"}
                                                    {foreach :unserialize($item['multi_pic']) as $picValue}
                                                    <div class="item">
                                                        <input type="hidden" name="picArr[]" value="{$picValue}">
                                                        <img src="__PUBLIC__/{$picValue}" width="100px" height="100px">
                                                        <div class="operate">
                                                            <i class="toleft">左移</i>
                                                            <i class="toright">右移</i>
                                                            <i class="del">删除</i>
                                                        </div>
                                                    </div>
                                                    {/foreach}
                                                    {/if}

                                                </div>
                                                <div class="alert alert-success" role="alert"
                                                     style="margin:10px 0;"><strong><span
                                                        class="glyphicon glyphicon-flag"></span>点击批量上传按钮上传多张图片:</strong>&nbsp;&nbsp;单张图片大小不超过500KB,格式为jpg,png,gif,jpeg
                                                </div>

                                            </div>

                                        </div>
                                    </div>

                                    <div class="ln_solid"></div>

                                    <div class="form-group">
                                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                                            <button type="submit" class="btn btn-primary">提交</button>
                                            <a type="reset" class="btn btn-success" onclick="history.go(-1)">返回</a>
                                        </div>
                                    </div>

                                </form>
                            </div>
                        </div>
                    </div>
                </div>


            </div>
            <!-- /page content -->

        </div>

    </div>
</div>

{include file="public_foot" /}
<!-- upload_arr -->
<script src="__STATIC__/js/upload.photos.js"></script>
<script type="text/javascript" src="__STATIC__/plupload/plupload.full.min.js"></script>
<!-- Times -->
<script src='__STATIC__/js/datepicker/WdatePicker.js'></script>
<!-- validform -->
<script src="__STATIC__/js/Validform_v5.3.2_min.js"></script>
<script src="__STATIC__/js/layer.js"></script>
<!-- upload -->
<script type="text/javascript" src="__STATIC__/js/uploadPreview.js"></script>
<!-- daterangepicker -->
<script src="__STATIC__/js/datepicker/daterangepicker.js"></script>


<script>

    $('#interval_timer').daterangepicker(null,
        function(start, end, label) {
            console.log(start.toISOString(), end.toISOString(), label);
        });
    // 组图排序 删除图片
    $(".toleft").live("click", function () {
        var item = $(this).parent().parent(".item");
        var item_left = item.prev(".item");
        if ($("#photos_area").children(".item").length >= 2) {
            if (item_left.length == 0) {
                item.insertAfter($("#photos_area").children(".item:last"));
            } else {
                item.insertBefore(item_left);
            }
        }

    })

    $(".toright").live("click", function () {
        var item = $(this).parent().parent(".item");
        var item_right = item.next(".item");
        if ($("#photos_area").children(".item").length >= 2) {
            if (item_right.length == 0) {
                item.insertBefore($("#photos_area").children(".item:first"));
            } else {
                item.insertAfter(item_right);
            }
        }
    })

    $(".del").live("click", function () {
        $(this).parent().parent(".item").remove();
    })
    // validform
    $(function () {
        $(".select2_single").select2({
            placeholder: "请选择分类",
            allowClear: true
        });
        $.Tipmsg.r = null;

        var showmsg = function (msg) {
            //假定你的店铺商品提示方法为showmsg， 在方法里可以接收参数msg，当然也可以接收到o及cssctl;
            alert(msg);
        }
        $("#registerForm").Validform({
            tiptype: function (msg) {
                layer.msg(msg);
            },
            tipSweep: true
        });


        // upload
        new uploadPreview({UpBtn: "up_img", DivShow: "imgdiv", ImgShow: "imgShow"});

        // select2



        $(":radio").click(function () {

            if (this.checked) {
                if ($(this).attr("id") == "freight_type_1") {
                    $("#immobilization").show();
                    $("#template").hide();
                }else{
                    $("#immobilization").hide();
                    $("#template").hide();
                }
            }
        });
    });

    // 组图上传
    var uploader = new plupload.Uploader({
        runtimes: 'html5,flash,silverlight,html4',
        browse_button: 'logo_upload_btn',
        url: "/index.php/client/shop_goods/uploadarr.html",
        flash_swf_url: '__STATIC__/plupload/Moxie.swf',
        silverlight_xap_url: '__STATIC__/plupload/Moxie.xap',
        filters: {
            max_file_size: '500kb',
            mime_types: [
                {title: "files", extensions: "jpg,png,gif,jpeg"}
            ]
        },
        multi_selection: true,
        init: {
            FilesAdded: function (up, files) {
                $("#btn_submit").attr("disabled", "disabled").addClass("disabled").val("正在上传...");
                var item = '';
                plupload.each(files, function (file) { //遍历文件
                    item += "<div class='item' id='" + file['id'] + "'><div class='progress'><span class='bar'></span><span class='percent'>0%</span></div></div>";
                });
//                alert(item.length);
//                if(item.length >= 2){
//                    alert('最多只能上传2张图片');
//                    return false;
//                }
                $("#photos_area").append(item);
                uploader.start();
            },
            UploadProgress: function (up, file) { //上传中，显示进度条
                var percent = file.percent;
                $("#" + file.id).find('.bar').css({"width": percent + "%"});
                $("#" + file.id).find(".percent").text(percent + "%");
            },
            FileUploaded: function (up, file, info) {

                var data = eval("(" + info.response + ")");

                $("#" + file.id).html("<input type='hidden' name='picArr[]' value='" + data.src + "'><img src='__PUBLIC__/" + data.src + "' alt='" + data.name + "' width='100px' height='100px'><div class='operate'><i class='toleft'>左移</i><i class='toright'>右移</i><i class='del'>删除</i></div>")
                $("#btn_submit").removeAttr("disabled").removeClass("disabled").val("提 交");
                if (data.error != 0) {
                    layer.msg(data.error);
                }
            },
            Error: function (up, err) {
                layer.msg(err.message);
                $("#btn_submit").removeAttr("disabled").removeClass("disabled").val("提 交");
            }
        }
    });
    uploader.init();
    // validform
    $(function () {

        $.Tipmsg.r = null;

        var showmsg = function (msg) {
            //假定你的店铺商品提示方法为showmsg， 在方法里可以接收参数msg，当然也可以接收到o及cssctl;
            alert(msg);
        }
        $("#registerForm").Validform({
            tiptype: function (msg) {
                layer.msg(msg);
            },
            tipSweep: true
        });

        // upload
        new uploadPreview({UpBtn: "up_img", DivShow: "imgdiv", ImgShow: "imgShow"});

    })
</script>
</body>

</html>
